library(readr)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(ggplot2)
library(ggthemes)
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
aqi_grouped <- read_csv("/home/ashish/data-visualization-lab/Air_Quality_Project/data/aqi_grouped.csv", show_col_types = FALSE)
fig <- aqi_grouped %>%
plot_ly(
x = ~year,
y = ~recordings,
color = ~Category,
frame = ~state_name,
text = ~state_name,
hoverinfo = "text",
type = 'scatter',
mode = 'markers'
)
fig <- fig %>% layout(
xaxis = list(
type = "log"
),
yaxis = list(
range=c(0,800)
)
)
fig
filter_five_years <- dplyr::filter(aqi_grouped, year %in% c("1980", "1985", "1990", "1995", "2000","2005", "2010", "2015", "2020", "2021", "2022"))
vbP <- c('#7fbf7b','#b30000','#fc8d59','#67a9cf','#c994c7','#016c59')
p <- ggplot(filter_five_years, aes(state_name))
p + geom_bar(aes(fill=Category)) + scale_fill_manual(values=vbP) + theme_economist() + theme(axis.text.x = element_text(size=12, angle = 90, vjust = 0.5, hjust=1)) + labs(x ='State Names')
